From 99695250c86ea80fe00e1259bb51e77ac6247e91 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Tue, 21 Aug 2007 19:32:42 +0000 Subject: [PATCH] gbfile: Check return code after read with fixed buffer length. --- gpsbabel/gbfile.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gpsbabel/gbfile.c b/gpsbabel/gbfile.c index 3b3489e2a..978c9e70f 100644 --- a/gpsbabel/gbfile.c +++ b/gpsbabel/gbfile.c @@ -597,7 +597,8 @@ gbfgetint32(gbfile *file) { char buf[4]; - gbfread(&buf, 1, sizeof(buf), file); + is_fatal((gbfread(&buf, 1, sizeof(buf), file) != sizeof(buf)), + "%s: Unexpected end of file (%s)!\n", file->module, file->name); if (file->big_endian) return be_read32(buf); @@ -614,7 +615,8 @@ gbfgetint16(gbfile *file) { char buf[2]; - gbfread(&buf, 1, sizeof(buf), file); + is_fatal((gbfread(&buf, 1, sizeof(buf), file) != sizeof(buf)), + "%s: Unexpected end of file (%s)!\n", file->module, file->name); if (file->big_endian) return be_read16(buf); @@ -631,7 +633,8 @@ gbfgetdbl(gbfile *file) { char buf[8]; - gbfread(&buf, 1, sizeof(buf), file); + is_fatal((gbfread(&buf, 1, sizeof(buf), file) != sizeof(buf)), + "%s: Unexpected end of file (%s)!\n", file->module, file->name); return endian_read_double(buf, ! file->big_endian); } @@ -645,7 +648,8 @@ gbfgetflt(gbfile *file) { char buf[4]; - gbfread(&buf, 1, sizeof(buf), file); + is_fatal((gbfread(&buf, 1, sizeof(buf), file) != sizeof(buf)), + "%s: Unexpected end of file (%s)!\n", file->module, file->name); return endian_read_float(buf, ! file->big_endian); } -- 2.30.2